package library.view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.text.ParseException;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import library.controller.LibraryControllerListener;
import library.pojo.User;
import library.service.LibraryService;

@SuppressWarnings("serial")
public class TotalFrameSystem extends JFrame {
	private LibraryControllerListener libraryControllerListener;
	private JTabbedPane jTabbedPane;
	private ImageIcon icon;
	private User user;
	private JPanel panel1;
	private JPanel panel2;
	private JPanel panel3;
	private JPanel panel4;
	private JPanel panel5;
	private JPanel panel6;

	public static void main(String[] args) {
		User user = new User(null, null, null, null, null);
		TotalFrameSystem tf = new TotalFrameSystem(user);
	}

	public TotalFrameSystem(User user) {
		this.user = user;
		this.libraryControllerListener = new LibraryControllerListener();
		icon = new ImageIcon(MainJTPane.class.getResource("/title.png"));
		this.setIconImage(icon.getImage());
		setTitle("图书管理系统");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setBounds(345, 150, 1200, 750);
		this.add(mainFrame(libraryControllerListener), BorderLayout.CENTER);
		this.setLocationRelativeTo(null);
		this.setVisible(true);
	}

	/**
	 * 选项卡
	 */
	public JTabbedPane mainFrame(LibraryControllerListener libraryControllerListener) {
		jTabbedPane = new JTabbedPane();
		jTabbedPane.setFont(new Font("黑体", Font.BOLD, 20));
		jTabbedPane.setBackground(new Color(135, 206, 235));

		panel1 = new MainJTPane();
		panel5 = new ManageJPanel(LibraryService.findAllUser(), libraryControllerListener);
		panel6 = new UpdateMessage(libraryControllerListener, user, this, null, null);

		jTabbedPane.add("主界面", panel1);
		jTabbedPane.add("用户管理", panel5);
		jTabbedPane.add("个人信息", panel6);

		return jTabbedPane;
	}
}
